<script type="text/javascript">
customerTable();

function selectBaseCustomer(customerData) {
    var selectedId = $("#jqgrid").jqGrid("getGridParam", "selrow");
    var selectCustomerData;
    if (selectedId) {
        selectCustomerData = $("#jqgrid").getRowData(selectedId);
    }
    var customer = customerData || selectCustomerData;
    if (!customer) {
        alert("请先选择人员！");
        return;
    }
    $.baseCustomerSet(customer);
    $("#baseApiCustomerModal").modal('hide');
}

function clearBaseCustomer() {
    $.baseClearCustomer();
    $("#baseApiCustomerModal").modal('hide');
}
// jqGrid
function customerTable() {
    jQuery("#jqgrid").jqGrid({
        url: URL_PATH + "/baseApi/findCommonCustomers.shtml",
        datatype: "json",
        colNames: ['id', '公司编号', '公司姓名', '分享比例', '维护费', '交费日期', '备注'],
        colModel: [{
            name: 'id',
            index: 'id',
            align: "center",
            classes: "grid_cell",
            sortable: false,
            hidden: true
        }, {
            name: 'companycode',
            index: 'companycode',
            align: "center",
            classes: "grid_cell",
            sortable: false
        }, {
            name: 'customername',
            index: 'customername',
            width: 150,
            sortable: false
        }, {
            name: 'copeproportion',
            index: 'copeproportion',
            align: "center",
            classes: "grid_cell",
            sortable: false
        }, {
            name: 'maintenanceprice',
            index: 'maintenanceprice',
            align: "center",
            classes: "grid_cell",
            sortable: false
        }, {
            name: 'lastpaydate',
            index: 'lastpaydate',
            align: "center",
            classes: "grid_cell",
            sortable: false
        }, {
            name: 'memo',
            index: 'memo',
            align: "center",
            classes: "grid_cell",
            sortable: false
        }],
        rowNum: 15,
        prmNames: {
            page: "page.currentPage",
            rows: "page.pageSize"
        },
        rowList: [15, 50, 100, 300, 500, 800, 1000],
        pager: '#pager',
        multiselect: false,
        loadonce: false,
        viewrecords: true,
        ondblClickRow: function(rowid, iRow, iCol, e) {
            selectBaseCustomer($("#jqgrid").getRowData(rowid));
        },
        jsonReader: {
            root: "custList",
            cell: '',
            page: "page.currentPage",
            total: "page.totalPage",
            records: "page.rowCount",
            repeatitems: false
        },
        shrinkToFit: true,
        autoScroll: true,
        hidegrid: true,
        hiddengrid: false,
        height: 260,
        width: 830,
        rownumbers: true,
        rownumWidth: 30,
        loadComplete: function() {}
    });
}
</script>
<div id="baseApiCustomerModal" class="modal  in modal_bg" style="style=" overflow: hidden; z-index: 1070; display: block; margin-left: -364px; height: 440px; margin-top: -219px; "">
    <div class="modal-header bomb_header">
        <a class="close" data-dismiss="modal">&times;</a>
        <h3>选择公司</h3>
    </div>
    <div style="overflow: hidden; max-height: 500px;" class="list_bg">
        <div style="overflow: hidden; margin: 10px 10px 10px 20px;">
            <div style="overflow: hidden;">
                <table id="jqgrid" class="grid_table"></table>
                <div id="pager"></div>
            </div>
        </div>
    </div>
    <div class="modal-footer" style="border-top:none; box-shadow:none;">
        <a class="empty" style="color:#FFF; font-size:14px;" href="javascript:clearBaseCustomer()" id="queding">清空</a>
        <a class="ensure" style="color:#2e81e9; font-size:14px;" href="javascript:selectBaseCustomer()" id="queding">确定</a>
        <a href="javascript:void(0)" data-dismiss="modal" class="cancel" style="color:#2e81e9; font-size:14px;">取消</a>
    </div>
</div>
